#ifndef DES_MAIN_FORM
#define DES_MAIN_FORM

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <ImgList.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <Grids.hpp>
#include <Tabs.hpp>

#include "hcomps.h"
#include "HWindow.h"
#include "HButtonTab.h"
#include "HCFGStorage.h"
#include "HControlIO.h"
#include "HExcept.h"
#include "HMenus.h"
#include "HLog.h"
#include "BkList.h"
#include "HDesignPanel.h"
#include "HToolw97.h"

#include "XPMenu.hpp"
#include "TB97Ctls.hpp"
#include "TB97.hpp"
#include "TB97Tlwn.hpp"
#include "TB97Tlbr.hpp"
#include "AddOnTB97.hpp"

#include "ELDsgnr.hpp"
#include "oinspect.hpp"

PRECLASS( HRTBaseLink );

class TMainForm : public TForm {
__published:    // IDE-managed Components
        HToolWindow97 *tbPalette;
        HBottonsTab *buttons;
        TOpenDialog *open;
        TELDesigner *designer;
        TSaveDialog *save;
        TDock97 *TopDock;
        HExceptionDialog *HExceptionDialog1;
        HControlIO *cIO;
        HPopupMenu *pmDesign;
        TDock97 *LeftDock;
        TDock97 *RightDock;
        TDock97 *BottomDock;
        TELDesignPanel *DesignPanel;
        TTabSet *pgState;
        HMainMenu *mnuMain;
        TMenuItem *File1;
        TMenuItem *Exit2;
        TMenuItem *N6;
        TMenuItem *mnuSaveAs;
        TMenuItem *mnuSave;
        TMenuItem *Open2;
        TMenuItem *New2;
        TMenuItem *N8;
        TMenuItem *PasteSpecial1;
        TMenuItem *Paste2;
        TMenuItem *Copy2;
        TMenuItem *Cut2;
        TMenuItem *N9;
        TMenuItem *Undo1;
        TMenuItem *Selectall2;
        TMenuItem *Configure1;
        TMenuItem *Options1;
        TMenuItem *Close1;
        TMenuItem *Closeall1;
        TMenuItem *N5;
        TMenuItem *N7;
        TMenuItem *mnuWindows;
        TMenuItem *N1;
        TMenuItem *Next1;
        TMenuItem *Prev1;
        TMenuItem *mru11;
        TMenuItem *mru21;
        TMenuItem *mru31;
        TMenuItem *mru41;
        TMenuItem *mru51;
        TMenuItem *mru61;
        TMenuItem *mru71;
        TMenuItem *mru81;
        TMenuItem *mru91;
        TMenuItem *N3;
        HCfgStorage *cfg;
        HDesignPanel *DesignPlace;
        TTabControl *pgForms;
        TMenuItem *N4;
        TMenuItem *mnuSaveCfg;
        TMenuItem *Palettetoolbar1;
        TMenuItem *Bringtofront1;
        TMenuItem *Sendtoback1;
        TMenuItem *Align1;
        TMenuItem *Alignleft1;
        TMenuItem *Aligntop1;
        TMenuItem *Center1;
        TMenuItem *Horizontalcenter1;
        TMenuItem *ights1;
        TMenuItem *Bottoms1;
        TMenuItem *Aligntogrid1;
        TMenuItem *Align2;
        TMenuItem *Cut1;
        TMenuItem *Copy1;
        TMenuItem *Paste1;
        TMenuItem *PasteSpecial2;
        TMenuItem *N15;
        TMenuItem *Bringtofront2;
        TMenuItem *Sendtoback2;
        TMenuItem *Align3;
        TMenuItem *Aligntogrid2;
        TMenuItem *Align4;
        TMenuItem *Alignleft2;
        TMenuItem *Aligntop2;
        TMenuItem *ights2;
        TMenuItem *Bottoms2;
        TMenuItem *Center2;
        TMenuItem *Horizontalcenter2;
        TMenuItem *N12;
        TMenuItem *Objectinspector1;
        TMenuItem *Snaptogrid1;
        TMenuItem *Snaptogrid2;
        TImageList *MainImages;
        TMenuItem *N13;
        TMenuItem *N14;
        TMenuItem *N16;
        TMenuItem *N17;
        TMenuItem *N18;
        TMenuItem *N19;
        TXPMenu *XPMenu;
        HWindow *tbInspector;
        TSplitter *Splitter1;
        TPropertyHelp *PropertyHelp1;
        TObjectInspector *inspector;
        TMenuItem *N21;
        TMenuItem *N22;
        TMenuItem *mnuTextEdit;
        TMenuItem *N26;
        HLogComboBox *bComp;
        TPanel *DesPanel;
        TImageList *CompImages;
        TMenuItem *Ed1;
        TMenuItem *mnuDup;
        TMenuItem *D1;
        TTimer *keyTimer;
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall designerChangeSelection(TObject *Sender);
        void __fastcall designerChange(TObject *Sender);
        void __fastcall designerControlInserting(TObject *Sender,TControlClass &AControlClass);
        void __fastcall New1Click(TObject *Sender);
        void __fastcall Open1Click(TObject *Sender);
        void __fastcall idSaveClick(TObject *Sender);
        void __fastcall idSaveAsClick(TObject *Sender);
        void __fastcall Exit1Click(TObject *Sender);
        void __fastcall Design1Click(TObject *Sender);
        void __fastcall idECut(TObject *Sender);
        void __fastcall idECopy(TObject *Sender);
        void __fastcall idEPaste(TObject *Sender);
        void __fastcall idEDel(TObject *Sender);
        void __fastcall idMenuChecker(TObject *Sender,TMenuItem *Item);
        void __fastcall pgStateChange(TObject *Sender, int NewTab,bool &AllowChange);
        void __fastcall idESelAll(TObject *Sender);
        void __fastcall Close1Click(TObject *Sender);
        void __fastcall idCloseAllClick(TObject *Sender);
        void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
        void __fastcall Next1Click(TObject *Sender);
        void __fastcall Prev1Click(TObject *Sender);
        void __fastcall idMRUClick(TObject *Sender);
        void __fastcall BasePanelChange(TObject *Sender);
        void __fastcall Options1Click(TObject *Sender);
        void __fastcall mnuSaveCfgClick(TObject *Sender);
        void __fastcall idToolSwitch(TObject *Sender);
        void __fastcall idAToFront(TObject *Sender);
        void __fastcall idAToBack(TObject *Sender);
        void __fastcall idAGrid(TObject *Sender);
        void __fastcall idALeft(TObject *Sender);
        void __fastcall idATop(TObject *Sender);
        void __fastcall idARight(TObject *Sender);
        void __fastcall idABottom(TObject *Sender);
        void __fastcall idAVCenter(TObject *Sender);
        void __fastcall idAHCenter(TObject *Sender);
        void __fastcall idAlign(TObject *Sender);
        void __fastcall pgFormsMouseMove(TObject *Sender,TShiftState Shift, int X, int Y);
        void __fastcall cIOReadError(TReader *Reader,const AnsiString Message, bool &Handled);
        void __fastcall Objectinspector1Click(TObject *Sender);
        void __fastcall idASnapGrid(TObject *Sender);
        void __fastcall designerControlInserted(TObject *Sender,
          TControl *Control);
        void __fastcall cIOComponentCreate(TObject *Sender,
          TComponent *Component);
        void __fastcall pmDesignPopup(TObject *Sender);
        void __fastcall FormShortCut(TWMKey &Msg, bool &Handled);
        void __fastcall inspectorGetCellParams(TObject *Sender,
          TPropertyEditor *PropEdit, AnsiString &text, int Column,
          TFont *Font);
        void __fastcall N14Click(TObject *Sender);
        void __fastcall N16Click(TObject *Sender);
        void __fastcall N17Click(TObject *Sender);
        void __fastcall N18Click(TObject *Sender);
        void __fastcall N19Click(TObject *Sender);
        void __fastcall cfgSave(TObject *Sender);
        bool __fastcall tbInspectorHOnBeforeButtonPress(TObject *Sender,const PHCustomWindowBorder Border,const HCaptionButton_t Button);
        void __fastcall N22Click(TObject *Sender);
        void __fastcall mnuTextEditClick(TObject *Sender);
        void __fastcall N26Click(TObject *Sender);
        void __fastcall bCompChange(TObject *Sender);
        void __fastcall DesignPlaceResize(TObject *Sender);
        void __fastcall mnuDupClick(TObject *Sender);
        void __fastcall keyTimerTimer(TObject *Sender);

  protected:
    virtual void __fastcall Notification(TComponent* AComponent, TOperation Operation);
    virtual void __fastcall WndProc(Messages::TMessage& m);

  protected:
    bool FullSave( PFormItem p );
    void RefreshTabs( void );

    void Sync( PFormItem p );
    void Remove( PFormItem p );
    void SetWinMRU( TMenuItem *p );
    void ControlsChanged( void );
    void CfgChanged( void );
    void __fastcall SetControlsProps( TList *list );
    void __fastcall SetControlProps( TPersistent *ctl );
    void __fastcall DesignerMenuClick( TObject *Sender );

    TELDesignerLockMode GetFullLockMode( void );
    bool                CheckLockMode( ELDsgnr__4 lm );
    void                SwitchLockMode( ELDsgnr__4 l );

  private:
    FormArray     Forms;
    bool          FDesigning;
    bool          inChanges;
    bool          inDesignChanging;
    bool          IgnoreLoadErrors;
    int           FirstRealPopup;
    DWORD         LastShift;
    HKL           LastLayout;
  public:
    __fastcall TMainForm(TComponent* Owner);

    void __fastcall NewForm( void );
    void __fastcall LoadForm( CONSTSTR nm );
    bool __fastcall CloseForm( int idx, bool DoSave = true );
    void __fastcall FillCBList( void );

    void __fastcall ApplyKeyboard( void );
    void __fastcall ResetKeyboard( void );

    DEF_PROP_PP( bool,            Changed,          ;,; )
    DEF_PROP_PP( bool,            Designing,        ;,; )
    DEF_PROP_VP( int,             CurrentIndex,     ; )
     DEF_PROP_P( PFormItem,       Current,          { return Forms.Item(CurrentIndex); } )
};
//---------------------------------------------------------------------------
extern TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
